package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.AdminTempUser;
import com.fx.entity.SysConfig;
import com.fx.entity.SysUser;
import com.fx.mapper.SysConfigMapper;
import com.fx.service.SysConfigService;
import com.fx.util.IdWorker;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class SysConfigServiceImpl implements SysConfigService {
    @Autowired
    private SysConfigMapper sysConfigMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public SysConfig getById(String flId) {
        return sysConfigMapper.getById(flId);
    }

    @Override
    public List<SysConfig> getList(Map<String, Object> map) {
        return sysConfigMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return sysConfigMapper.queryCount(map);
    }

    @Override
    public int save(SysConfig sysConfig) {
        sysConfig.setFlId(String.valueOf(idWorker.nextId()));
        sysConfig.setFlCreatedTime(DateUtil.now());
        sysConfig.setFlCreator(((AdminTempUser) SecurityUtils.getSubject().getPrincipal()).getFlName());
        return sysConfigMapper.save(sysConfig);
    }

    @Override
    public int updateById(SysConfig sysConfig) {
        return sysConfigMapper.updateById(sysConfig);
    }

    @Override
    public int remove(String flId) {
        return sysConfigMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return sysConfigMapper.batchRemove(flIds);
    }

}
